<!--
 * @Author: your name
 * @Date: 2021-07-27 09:12:22
 * @LastEditTime: 2021-08-12 10:23:30
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \getHome2\src\components\evaluate\management.vue
-->
<!--新版本-->
<template>
  <div class="content">
    <div class="herdertop">
      <img src="../../assets/top.png" alt="" class="topImg" />
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>评价管理</el-breadcrumb-item>
        <el-breadcrumb-item>评价列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="center" style="padding-top: 0px;">
      <div class="hander">评价列表</div>

      <div class="entirety">
        <div class="search">
          <div class="news">
            <div class="userSearch">
              <el-select
                v-model="select"
                placeholder="请选择"
                @change="changeSelect"
              >
                <el-option
                  v-for="item in evaluateSearch"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
              <el-input v-model="input" placeholder="请输入"></el-input>
              <!-- <el-button
                icon="el-icon-search"
                @click="searchForUserInformation"
              ></el-button> -->
            </div>
          </div>

          <!--  账号状态搜索信息 -->
          <div class="demo-input-suffix">
            <div class="condition">
              <p style="width: 110px">服务时间:</p>
              <el-date-picker
                style="width: 95%"
                v-model="rangedatetime"
                type="datetimerange"
                range-separator="至"
                @change="changeendDate"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>

              <el-button
                style="background-color:#fd804c;color: #fff;margin-left: 8px"
                @click="downloadNew"
                :disabled="total == 0 ? true : false"
                >导出</el-button
              >
              <el-button
                style="background-color:#fd804c;color: #fff;"
                @click.native.prevent="isSelect"
                >查询</el-button
              >
              <el-button type="warning" @click.native.prevent="isEmpty"
                >清空</el-button
              >
            </div>
          </div>
        </div>
      </div>

      <div style="margin-top: 10px" class="entirety"></div>

      <div class="tab">
        <el-table :data="memOrderVo">
          <!-- <el-table-column type="selection" width="50"> </el-table-column> -->
          <el-table-column label="评价项" prop="qaQuestion">
            <template slot-scope="scope">
              <div>
                {{ scope.row.satisfactionQuestion }}
              </div>
              <div>{{ scope.row.qaQuestion }}<br /></div>
            </template>
          </el-table-column>

          <el-table-column label="用户选择" prop="satisfactionAnswer">
            <template slot-scope="scope">
              <div>
                {{ scope.row.satisfactionAnswer }}
              </div>
              <div>{{ scope.row.qaAnswers }}<br /></div>
            </template>
          </el-table-column>
          <el-table-column label="用户备注" prop="buyerRemark">
            <template slot-scope="scope">
              <div>
                {{ scope.row.buyerRemark }}
              </div>
            </template>
          </el-table-column>

          <el-table-column label="用户昵称" prop="nickname">
            <template slot-scope="scope">
              <div>
                {{ scope.row.nickname }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="用户手机号" prop="phone">
            <template slot-scope="scope">
              <div>
                {{ scope.row.phone }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="员工姓名" prop="staffName">
            <template slot-scope="scope">
              <div>
                {{ scope.row.staffName }}
              </div>
            </template>
          </el-table-column>

          <el-table-column label="员工手机号" prop="staffPhone">
            <template slot-scope="scope">
              <div>
                {{ scope.row.staffPhone }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="订单编号" prop="orderNo" width="300">
            <template slot-scope="scope">
              <div>
                {{ scope.row.orderNo }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="工单编号" prop="workOrderNo">
            <template slot-scope="scope">
              <div>
                {{ scope.row.workOrderNo }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            label="预约时间"
            prop="expectDeliveryTime"
            width="150"
          >
            <template slot-scope="scope">
              <div>
                {{ scope.row.expectDeliveryTime }}
              </div>
            </template>
          </el-table-column>

          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                @click.native.prevent="seeWorkOrder(scope.row.orderNo)"
                style="color: #fc9e76;"
                type="text"
                size="small"
              >
                查看订单
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="block">
        <div class="left"></div>
        <div class="right">
          <el-pagination
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage1"
            :page-size="pageSize"
            :total="total"
          >
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import list from "../../mock/data";
import Bus from "../../api/bus";
import moment from "moment";

export default {
  data() {
    return {
      input: "",
      select: 1,
      currentPage1: 1, //当前页码
      pageSize: 20, //每页显示的个数
      memOrderVo: [],
      total: 0,
      search: "",
      nickname: "",
      orderNo: "",
      phone: "",
      endTime: "",
      startTime: "",
      rangedatetime: [],
      evaluateSearch: [
        { value: 1, label: "用户昵称" },
        { value: 2, label: "订单编号" },
        { value: 3, label: "用户手机号" }
      ],
      dialogFormVisible: false,
      formLabelWidth: "120px",
      dialogStatus: "create"
    };
  },
  created() {
    this.getList();
  },

  methods: {
    //导出
    downloadNew() {
      console.log(
        "orderNo,,,,,",
        this.currentPage1,
        this.pageSize,
        this.phone,
        this.startTime,
        this.endTime,
        this.nickname,
        this.orderNo
      );
      if (window.location.host == "hs.xstarlife.com") {
        window.location.href = `https://hs.xstarlife.com/api/hssorderadmin/order/memOrder/exportCommentExcel?page=${this.currentPage1}&size=${this.pageSize}&phone=${this.phone}&startTime=${this.startTime}&endTime=${this.endTime}&nickname=${this.nickname}&orderNo=${this.orderNo}`;
      } else {
        window.location.href = `https://m.goltestarlife.com/hssorderadmin/order/memOrder/exportCommentExcel?page=${this.currentPage1}&size=${this.pageSize}&startTime=${this.startTime}&endTime=${this.endTime}&nickname=${this.nickname}&orderNo=${this.orderNo}`;
      }
    },
    changeendDate(data) {
      this.startTime =
        (data && moment(data[0]).format("YYYY-MM-DD HH:mm:ss")) || "";
      this.endTime =
        (data && moment(data[1]).format("YYYY-MM-DD HH:mm:ss")) || "";
    },
    isSelect() {
      if (this.select == 1) {
        this.nickname = this.input || "";
      } else if (this.select == 2) {
        this.orderNo = this.input || "";
      } else if (this.select == 3) {
        this.phone = this.input || "";
      }
      (this.currentPage1 = 1), (this.pageSize = 20), this.getList();
    },

    isEmpty() {
      (this.input = ""),
        (this.select = 1),
        (this.currentPage1 = 1), //当前页码
        (this.pageSize = 20), //每页显示的个数
        (this.search = ""),
        (this.nickname = ""),
        (this.orderNo = ""),
        (this.phone = ""),
        (this.endTime = ""),
        (this.startTime = ""),
        (this.rangedatetime = []),
        this.getList();
    },

    // 总数据.slice((当前页码—1)*每页显示的个数)，（当前页码*每页的个数）,
    handleSizeChange(val) {
      //改变每页显示的个数
      //console.log(`每页 ${val} 条`);
      this.currentPage1 = 1;
      this.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      //改变当前页码
      //console.log(`当前页: ${val}`);
      this.currentPage1 = val;
      this.getList();
    },

    // 跳转订单详情
    seeWorkOrder(orderNo) {
      this.$router.push({
        path: "/orderdetails",

        query: {
          orderNo: orderNo
        }
      });
    },
    getList() {
      this.$http({
        url: "/hssorderadmin/order/memOrder/memOrderGetList",
        method: "POST",
        data: {
          nickname: this.nickname,
          orderNo: this.orderNo,
          startTime: this.startTime,
          endTime: this.endTime,
          phone: this.phone,
          page: this.currentPage1,
          size: this.pageSize
        }
      }).then(res => {
        this.memOrderVo = res.list;
        this.total = parseInt(res.total);
      });
    },
    changeSelect(newvalue) {
      this.nickname = "";
      this.orderNo = "";
      this.phone = "";
      this.input = "";
    }
  }
};
</script>

<style scoped lang="scss">
.hander {
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: 900;
}
.herdertop {
  height: 8vh;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.topImg {
  margin-right: 20px;
}
.tab {
  margin-top: 3%;
}
.entirety {
  width: 95%;
  margin: 10px;
  border: 7px solid #fafafa;
  border-radius: 10px;
  .basic {
    font-size: 18px;
    font-weight: 900;
    margin-top: 2%;
    margin-bottom: 1%;

    margin-left: 1%;
  }
}
.input-with-select {
  width: 73%;
}
.down {
  width: 108px;
}
.block {
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0 10px 0 10px;
}
.left {
  font-size: 15px;
}
.top {
  font-size: 15px;
}
.demo-input-suffix {
  margin-left: 1%;
}
.news {
  margin-left: 1%;
}
.userSearch {
  display: flex;
  /deep/ .el-input__inner {
    box-sizing: border-box;
    height: 40px;
    border-radius: 0;
    width: 132px;
    border: 1px solid #dcdfe6;
  }
  /deep/ .el-icon-arrow-up:before {
    position: relative;
    top: -4px;
  }
  /deep/ .el-button {
    height: 40px;
    border-radius: 0;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    position: relative;
    .el-icon-search {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-right: none;
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
  }
}
.condition {
  width: 95%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  p {
    font-size: 14px;
  }
}
</style>
